package com.czk.dao;

import com.czk.entity.User;
import org.apache.ibatis.annotations.*;
import sun.nio.cs.US_ASCII;

import java.util.List;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/12/12 11:38
 */
public interface UserMapper {
    /**
     * 获取全部
     * @return
     */
    @Select("select * from user")
    List<User> selectAll();

    /**
     * 通过name和密码查询
     * @param name
     * @param password
     * @return
     */
    @Options(useGeneratedKeys = true)
    @Select("select * from user where name=#{name} and password=#{password}")
    List<User> selectByNameAndPassword(@Param("name") String name,@Param("password") String password);

    /**
     * 更新
     * @param user
     */
    @Update("update user set password=#{password},name=#{name} where id=#{id}")
    void updateUser(User user);

    /**
     * 插入数据
     * @param user
     * @return
     */
    @Options(useGeneratedKeys = true)
    @Insert("insert into user(name,password) values(#{name},#{password})")
    int insertUser(User user);
}
